package com.bistu.xiong.tulingrobotchat.frags.main;


import android.view.View;
import android.widget.ImageView;

import com.bistu.xiong.common.app.Fragment;
import com.bistu.xiong.tulingrobotchat.R;
import com.bistu.xiong.tulingrobotchat.activities.TuLingActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.ViewTarget;

import butterknife.BindView;
import butterknife.OnClick;

public class HomeFragment extends Fragment {

    @BindView(R.id.appbar)
    View appBar;

    @BindView(R.id.tuling)
    ImageView tulingImg;

    public HomeFragment() {
        // Required empty public constructor
    }

    @Override
    protected int getContentLayoutId() {
        return R.layout.fragment_main_home;
    }

    @Override
    protected void initData() {
        super.initData();
    }

    @Override
    protected void initWidget(View root) {
        super.initWidget(root);
        //使用Glide加载图片给Appbar设置背景
        Glide.with(this)
                .load(R.drawable.bg_src_morning)
                .centerCrop()
                .into(new ViewTarget<View,GlideDrawable>(appBar) {
                    @Override
                    public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                        this.view.setBackground(resource.getCurrent());
                    }
                });
    }

    @OnClick(R.id.tuling)
    void tilingChat(){
        //跳转到聊天界面
        TuLingActivity.show(getActivity());
    }
}








